<script setup>
import { storeToRefs } from 'pinia'
import { useAppStore } from './stores/appStore'
import AppList from './components/AppList.vue'
import Workspace from './components/Workspace.vue'

const store = useAppStore()
const { applications, activeAppId, initialized } = storeToRefs(store)
</script>
<template>
  <div v-if="initialized" class="container">
    <div class="sidebar">
      <AppList 
        :applications="applications"
        @create-app="store.addApplication()"
        show-logo
      />
    </div>
    <div class="main-content">
      <Workspace 
        v-if="activeAppId"
        :key="activeAppId"
      />
      <div v-else class="empty-workspace">
        请选择或新建一个应用
      </div>
    </div>
  </div>
  <div v-else class="loading">
    正在加载数据...
  </div>
</template>

<style scoped>
.loading {
  display: flex;
  height: 100vh;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #666;
}
.container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.sidebar {
  width: 280px;
  border-right: 1px solid #e4e7ed;
  background: #f5f7fa;
}

.main-content {
  flex: 1;
  padding: 20px;
  width: calc(100vw - 280px);
}

.empty-workspace {
  display: flex;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: #909399;
}
</style>
